var i = require("../../@babel/runtime/helpers/createForOfIteratorHelper"), t = getApp();

Component({
    options: {
        addGlobalClass: !0
    },
    properties: {
        isNewUser: {
            type: Boolean,
            value: !1
        },
        info: {
            type: Object,
            observer: function(o, e) {
                var a = [];
                if (o) {
                    if (o.couponList && o.couponList.length > 0) {
                        var n, s = i(o.couponList);
                        try {
                            for (s.s(); !(n = s.n()).done; ) {
                                var p = n.value, r = void 0;
                                r = 1 == p.sceneType ? o.photoMap.free.imgUrl : o.photoMap.coupon.imgUrl, a.push({
                                    icon: r,
                                    title: p.couponName,
                                    desc: p.validDay ? "有效期：" + p.validDay + "天" : "有效期至：" + p.endTime,
                                    count: 1
                                });
                            }
                        } catch (i) {
                            s.e(i);
                        } finally {
                            s.f();
                        }
                    }
                    o.tipCardNum > 0 && a.push({
                        icon: o.photoMap.tip.imgUrl,
                        title: "提示卡",
                        desc: "有效期：" + o.tipCardDays + "天",
                        count: o.tipCardNum
                    }), o.displayCardNum > 0 && a.push({
                        icon: o.photoMap.show.imgUrl,
                        title: "显示卡",
                        desc: "有效期：" + o.displayCardDays + "天",
                        count: o.displayCardNum
                    });
                }
                this.setData({
                    isLogin: t.isLogin(),
                    dataList: a
                });
            }
        }
    },
    data: {},
    pageLifetimes: {
        show: function() {
            this.setData({
                isLogin: t.isLogin()
            }), this.data.isLogin && !this.data.isNewUser && this.closeOnTap();
        }
    },
    methods: {
        nothing: function() {},
        ticketOnTap: function() {
            this.triggerEvent("onTicket", {});
        },
        loginOnTap: function() {
            wx.navigateTo({
                url: "/pages/login/login"
            }), this.closeOnTap();
        },
        closeOnTap: function() {
            this.setData({
                info: null
            }), this.triggerEvent("onClose", {});
        }
    }
});